package com.pds.web.spotCheck.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.operationLog.annotation.OprLog;
import com.pds.web.spotCheck.entity.PdsEnvironmentExamine;
import com.pds.web.spotCheck.service.PdsEnvironmentExamineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 监管部门考核机构表
 *
 * @author srf sunlightcs@gmail.com
 * @since 1.0.0 2023-12-26
 */
@Api(tags="监管部门考核机构")
@RestController
@RequestMapping("/environmentExamine")
public class PdsEnvironmentExamineController extends BaseController {

    @Resource
    private PdsEnvironmentExamineService pdsEnvironmentExamineService;

    /**
     * 分页查询抽查记录
     *
     *   pageNum/pageSize分页字段
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("分页查询抽查记录")
    @GetMapping("/page")
    public TableDataInfo pageEnvironmentExamine(PdsEnvironmentExamine pdsEnvironmentExamine){
        startPage();
        List<PdsEnvironmentExamine> list = pdsEnvironmentExamineService.selectList(pdsEnvironmentExamine);
        return getDataTable(list);
    }

    /**
     * 查询抽查记录列表
     *
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("查询抽查记录列表")
    @GetMapping("/list")
    public R<List<PdsEnvironmentExamine>> listEnvironmentExamine(PdsEnvironmentExamine pdsEnvironmentExamine){
        List<PdsEnvironmentExamine> list = pdsEnvironmentExamineService.selectList(pdsEnvironmentExamine);
        return R.ok(list);
    }

    /**
     * 根据ID查询抽查记录
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("抽查记录详情")
    @GetMapping("/queryById/{id}")
    public R<PdsEnvironmentExamine> queryEnvironmentExamineById(@PathVariable("id")Long id) {
        return R.ok(pdsEnvironmentExamineService.queryById(id));
    }

    /**
     * 创建抽查记录
     * @param pdsEnvironmentExamine 记录
     * @return 抽查记录
     */
    @OprLog(content = "创建抽查记录")
    @ApiOperation("创建抽查记录")
    @PostMapping("/add")
    public R<PdsEnvironmentExamine> addEnvironmentExamine(@RequestBody PdsEnvironmentExamine pdsEnvironmentExamine){
        return R.ok(pdsEnvironmentExamineService.insert(pdsEnvironmentExamine));
    }

    /**
     * 修改抽查记录
     * @param pdsEnvironmentExamine 记录
     * @return 成功标识
     */
    @ApiOperation("修改抽查记录")
    @PutMapping("/edit")
    public R<Boolean> editEnvironmentExamine(@RequestBody PdsEnvironmentExamine pdsEnvironmentExamine){
        return R.ok(pdsEnvironmentExamineService.update(pdsEnvironmentExamine));
    }

    /**
     * 根据ID删除抽查记录
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @ApiOperation("删除抽查记录")
    @DeleteMapping("/delete")
    public R<Boolean> deleteEnvironmentExamineById(@RequestParam Long id) {
        return R.ok(pdsEnvironmentExamineService.deleteById(id));
    }

}